import React from 'react';
import { Icon } from 'antd';
import LinkTo from '@/components/LinkTo';
import { eventTrack } from '@/utils/track';
import styles from './QuestionButton.less';

const QuestionButton = ({ blank, ...rest }) => {
    if (blank) {
        return (
            <a
                className={styles.questionLink}
                href={rest.to}
                target="_blank"
                rel="noopener noreferrer"
                style={rest.style}
                onClick={() => {
                    const res = rest.to;
                    let path = 'organization_views_help_click';
                    if (res === '/personal/portal/article?page=orgList') {
                        path = 'organization_orgList_help_click';
                    } else if (res === '/personal/portal/article?page=staff') {
                        path = 'organization_staff_help_click';
                    }
                    // 埋点
                    eventTrack({
                        eventName: path
                    });
                }}
            >
                帮助&nbsp;
                <Icon type="question-circle" />
            </a>
        );
    }
    return (
        <LinkTo className={styles.questionLink} {...rest}>
            帮助&nbsp;
            <Icon type="question-circle" />
        </LinkTo>
    );
};

export default QuestionButton;
